The Absolute Beginners Guide To Amos ------------------------------------- Chapter Five ------------- In this chapter we are going to discover the mysteries of loading a picture from disk and displaying it on screen, before we can actually get around to this there are a few important things you must learn, the first is about screens and the second is strings, here we go. SCREENS: -------- Amos has an excellent range of screen commands where the user can do almost anything. We can create custom screens changing the size, amount of colours width and height and other things. We are not going to delve too deeply here as it will just confuse you. In keeping with this tutorial I am just going to explain the minimum amount of commands you need to know about to understand how the example program works. There are at least four ways that we can load in a screen from disk, I intend to cover three of them in this chapter as pictures play quite a large part in games as title screens, backgrounds etc. One way to load a picture is manually, we can press ESCAPE and type in LOADIFF "PICTURE NAME",0 ------------------------ Which will load in a picture to screen 0. Screen 0 is the screen you are looking at and is created by Amos automatically. You can create other screens but we will be covering that later so don`t worry about that for now, also don`t worry about understanding the above load command yet I will explain further in a minute. Using this method is really only for checking or SPACKING a picture into a memory bank which we will cover later, but I thought I would give it a quick mention here to ease you into the idea. The second way to load a screen is from inside your program. Let`s say you wish to load a title screen for the start of your game this is what you could do: HIDE LOADIFF"DF0: PICS/SONIC.IFF",0 WAIT KEY: EDIT Yes that is all it is! We could squash all that on to one line if we wanted to, like this: HIDE:LOADIFF"DF0: PICS/SONIC.IFF",0: WAIT KEY: EDIT It`s not so easy to read but if you know what it does it`s OK. This is just a habit I have, I prefer my programs to be like this as long as it is not a complex part of the program then it keeps it out of the way, you don`t have to do this so don`t worry about it. OK here is a detailed examination of the above program: HIDE ---- HIDEs the mouse pointer LOADIFF ------ Tells Amos we want to LOAD an IFF picture file. "DF0: ---- Tells Amos the drive to use, change this to DF1: if you are using your external drive. PICS/SONIC.IFF" --------------- Is the name of the picture we want to load and it is stored in the PICS drawer on this disk. ,0 -- The screen to load the picture into for displaying, Screen 0 as explained earlier is the default screen already created for us by Amos, as screen 0 is the actual screen we are looking at we will see the picture displayed automatically. WAIT KEY: EDIT -------------- Look up your notes or see the tips in EXAMPLE5.Amos OK if you read the above a few times and messed with EXAMPLE5.Amos I think you will have a good idea of how this all works. I said earlier that we will cover three ways we to load a picture into Amos, well suppose you had written an art program and you had to let the user LOAD in any picture he/she wanted. The above examples would be useless because we can`t know the name of the file to load. The solution is the Amos file selector, but before we can continue I am going to have to introduce you to the string, ($) the dollar sign, is known as STRING and $ represents any letter or combination of letters to hold a variable, look up your notes on variables. The difference between the numerical variable and the $ variable is obvious when you look at the following examples: Numerical variables we learnt about earlier: A AVARIABLE TT these can be assigned numbers that can be changed with INC, DEC etc. String variables: A$ AVARIABLE$ TT$ These can be assigned text like this: A$="LOTS OF TEXT AND STUFF, EVEN NUMBERS IF YOU LIKE 1234567890" Remember the PRINT command? What we were doing, although not realizing it at the time, was assigning a string of text to tell PRINT what to PRINT, in the same way we can assign text to a string variable, which is normally inside the familiar quote marks " " If you are having trouble wrapping your head around this concept then that makes you a normal human, if you understand the string concept from the explanation above alone then you are well on your way to stardom. Right I am not going to dwell on strings for too long as I don`t want to put you off, but you will see why I had to mention strings in a moment. Here is how to bring up the Amos file requester so that the user can select any picture file, load it and display it on screen: See EXAMPLE5_1.Amos ------------------- F$=fsel$("*.*","","LOAD A PICTURE") IF F$="" THEN EDIT HIDE LOAD IFF F$,0 WAIT KEY: EDIT Don`t panic, here`s the breakdown: F$=fsel$("*.*","","LOAD A PICTURE") ----------------------------------- Oh no! Look at that first line, it`s not so bad as it looks, honest guv! The good news is you don`t have to understand exactly how this line works, all you need to understand is that F$ will hold the exact filename of whatever file the user has selected with the mouse, don`t worry about how each part of this line works it`s irrelevant except that when you type it in it has to be exactly as above, all the quotes commas and brackets need to be in the right place, of course you can put in any text at the end of the line that you like such as "LOAD A PIC" or "SELECT A PICTURE" or nothing at all, like this "" this is two quotes which is an empty string, you also could change the first F$ to anything like FILESELECT$, FF$, WIBBLE$ or ABC$ but you will have to change the F$ in line 4 to the same. IF F$="" THEN EDIT ------------------ In English this would sound like: IF the string of text held in F$ is equal to nothing THEN jump to the EDITor. OK, it`s new concept time again the IF THEN structure is a powerful and often use process, here are some real life examples: IF the kettle has boiled THEN switch it off IF it is raining THEN put hat on IF petrol is low THEN fill the tank IF F$ equals nothing THEN jump to editor Just make a note that the IF THEN structure is as follows, IF (do a check on something) THEN (execute something if true) -- ---- The point is if the IF part (the question if you like) is true the THEN part of the line will be executed, furthermore if the IF part is false then Amos will ignore the rest of the line, example: (the kettle isn`t boiling yet) IF the kettle has boiled THEN switch it off continue with program because the IF part was false So getting back to F$, IF F$ does NOT contain the empty string "" then Amos will not go to the EDITor but will continue on to the next instruction which is: HIDE ---- We are hiding the mouse just to keep things tidy, we didn`t HIDE it earlier in the program as the user needed to use it to select the file with. LOAD IFF F$,0 ------------- LOADIFF tells Amos to prepare to LOAD an IFF picture. F$ holds the name of the file the user has selected. The 0 is the screen the picture will be loaded into and viewed, screen 0 is the default screen as described earlier in this chapter. WAIT KEY: EDIT -------------- If all went well and the user selected an IFF file the picture should now be displayed on your screen, Amos will WAIT for a KEY press then return you to the EDITor. End of chapter five.